-
Notifications
You must be signed in to change notification settings - Fork 22
支持多语言(插件) #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
neveler
wants to merge
12
commits into
HMCL-dev:main
Choose a base branch
from
neveler:dev-i18n
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
支持多语言(插件) #268
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
以上文件保留,其余可以删除 |
Member
将 下载 集合的文章排除就好 |
7aa9e0f to
a05d6e8
Compare
af0ed34 to
e30a31c
Compare
baf5b21 to
dd80d7c
Compare
886ac95 to
ec39721
Compare
de3df7d to
565df46
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
支持多语言(插件)
该方案依赖我向上游提交的一个 PR 其作用是使 UI 语言能够优先依据
page.locale进行判断。ui-textusingpage.localewhen available mmistakes/minimal-mistakes#5368介绍
二级后缀自动作为
page.locale插件会根据文件名的二级后缀为文章指定
page.locale详情如下:_config.yml中配置字符串类型参数locale作为系统的默认语言区域代码_config.yml中配置字符串数组类型参数locales例如locales: [zh-Hans, zh-Hant, en]表示支持的语言区域代码列表,其中可以省略默认语言区域代码插件会在 site pre_render 时期遍历所有页面
Page与文档Document并根据文件名结合上面两个参数判断当前文档的语言区域代码。以配置locale: zh-Hans与locales: [zh-Hant, en]为例index.mdindex.es.md的文件名中均未命中配置列表中受支持的代码,因此使用默认代码zh作为page.locale而help.en.md与faq.zh-Hant.md会分别使用en与zh-Hant作为page.locale。自动配置多语言页面
page.permalink插件要求内容必须存在默认语言版本,无默认语言版本的内容不会被插件处理,等价于
i18n: false配置。插件会根据默认语言页面的
page.permalink自动为多语言页面配置page.permalink为/{locale}/{default_permalink}假设/test/a.md对应的page.permalink为/test-a.html那么/test/a.en.md对应的page.permalink则为/en/test-a.html。为不存在的语言版本提供回退页面
如果一篇文章并没有完整的支持所有的语言版本,在用户访问不存在的语言版本页面时用户会看到一个回退页面而非 404 页面。用户可以通过
_data/plugins/i18n/fallback.yml文件配置回退规则,详情如下:其它
需要启用多语言的页面需要配置
i18n: true如下所示:待做清单
多语言支持
部分完成,已支持
site.titlesite.descriptionsite.date_format部分完成,已支持
feedsitemap/test.html: #帮助
/en/test.html: #help
/test.html:
[demo](/_docs/demo.md)=>/demo.html/en/test.html:
[demo](/_docs/demo.md)=>/en/demo.html待合并 PR 的多语言支持
其它
关联 ISSUES
预览